<template>
	<view class="conter">
		<header-box :title="title"></header-box>
		<view class="text-tab">
			<view class="flex-box box-width">
				<view class="" @click="redactShow = true">
					创建日期
				</view>
				<view class="" @click="redactShow1 = true">
					关键字
				</view>
				<view class="" @click="redactShow2 = true">
					仓库
				</view>
			</view>
			<view class="box" v-for="(item, index) in textList" :key="index">
				<view class="box-title">
					<view class="">
						{{item.company}}
						<!-- 还 -->
					</view>
					<!-- <view class="" v-else>
						{{item.company}}借出
					</view> -->
					<!-- <view class="" >
						{{item.company}}
					</view> -->
					<view class="" style="font-weight: 400;">
						{{item.store}}
					</view>
				</view>
				<view class="box-data">
					{{item.createtime}}
				</view>

				<view class="flex-box" style="height: 70rpx;">
					<view class="">
						备注：{{item.memo}}
					</view>
					<navigator :url="'/pages/putStock/shoppingInfo?infoId=' + item.id + '&stock=' + stock" class=""
						style="color: #7278EC;">
						查看商品>>
					</navigator>
				</view>
			</view>
		</view>


		<navigator url="/pages/removeStock/addStock" class="add">
			<image src="../../static/index/add.png" mode=""></image>
		</navigator>




		<!-- 顶部弹层 -->
		<u-popup v-model="redactShow" mode="top" width="100%" border-radius="40">
			<!-- <view class="padd-text" v-for="(item, index) in list" :key="index" @click="elect(item, index)">
				<text :class="[index == tabText ? 'color-text' : 'none-color']">{{item.name}}</text>
			</view> -->

			<!-- 公共头部 -->
			<header-box :title="title"></header-box>
			<view style="padding: 13rpx 23rpx;
				font-family: PingFang SC;
				background-color: #EBEBF0;
				color: #333333; width: 140rpx;
				font-size: 24rpx; margin: 30rpx;" @click="redactShow = true">创建日期</view>
			<view class="text-fw" style="margin-left: 30rpx; margin-bottom: 30rpx;">
				搜索创建日期
			</view>
			<!-- <view class="flex-box1" style="margin-left: 30rpx;">
					<view class="f-1 flex justify-center">
						不限
					</view>
					<view class="f-1 flex justify-center">
						今日
					</view>
					<view class="f-1 flex justify-center">
						昨日
					</view>
				</view>
				<view class="flex-box2" v-for="(item, index) in textList" :key="index" >
					<view class="f-1 flex justify-center" >
						{{item.text}}
					</view>
					<view class="f-1 flex justify-center">
						华南总仓
					</view>
					<view class="f-1 flex justify-center">
						-20
					</view>
				</view> -->
			<view class="box1">
				<view class="box-bgc" @tap="show1 = true">
					{{dataTime ? dataTime : '开始时间'}}
				</view>
				-
				<view class="box-bgc" @tap="show2 = true">

					{{endTime ? endTime : '结束日期'}}
				</view>
			</view>
			<view class="search-box bg-gradual-green" @tap="search">
				搜索
			</view>
		</u-popup>


		<u-popup v-model="redactShow1" mode="top" width="100%" border-radius="40">
			<!-- <view class="padd-text" v-for="(item, index) in list" :key="index" @click="elect(item, index)">
				<text :class="[index == tabText ? 'color-text' : 'none-color']">{{item.name}}</text>
			</view> -->

			<!-- 公共头部 -->
			<header-box :title="title"></header-box>
			<view style="padding: 13rpx 23rpx;
				font-family: PingFang SC;
				background-color: #EBEBF0;
				color: #333333; width: 140rpx;
				font-size: 24rpx; margin: 30rpx;" @click="redactShow = true">关键字</view>
			<view class="text-fw" style="margin-left: 30rpx; margin-bottom: 30rpx;">
				搜索关键字
			</view>
			<view class="" style="width: 90%;
					height: 70rpx;
					background-color: #F5F5FA;
					margin: 20rpx auto 0;
					border-radius: 10rpx;">
				<input type="text" v-model="valText" placeholder="搜索备注" style="height: 70rpx; padding-left: 20rpx;"
					placeholder-style="padding-left: 16rpx" />
			</view>
			<view class="search-box bg-gradual-green" @tap="search1">
				搜索
			</view>
		</u-popup>





		<u-popup v-model="redactShow2" mode="top" width="100%" border-radius="40">
			<!-- <view class="padd-text" v-for="(item, index) in list" :key="index" @click="elect(item, index)">
				<text :class="[index == tabText ? 'color-text' : 'none-color']">{{item.name}}</text>
			</view> -->

			<!-- 公共头部 -->
			<header-box :title="title"></header-box>
			<view style="padding: 13rpx 23rpx;
				font-family: PingFang SC;
				background-color: #EBEBF0;
				color: #333333; width: 140rpx;
				font-size: 24rpx; margin: 30rpx;
				text-align: center;">仓库</view>
			<view class="text-fw" style="margin-left: 30rpx; margin-bottom: 30rpx; ">
				仓库
			</view>
			<view class="cen">
				<view class="padding-eft" v-for="(item, index) in listFrom" :key="index" @tap="search4(item.id)">
					<view class="">
						{{item.name}}
					</view>
				</view>
			</view>
			<view class="" style="height: 50rpx;">
			</view>
		</u-popup>





		<u-popup v-model="popupShow" mode="center" width="70%" height="280rpx" border-radius="10">
			<view class="input-text">
				商品分类
			</view>
			<view class="input-val">
				<input type="text" value="" style="background-color: #F0F0F0; text-align: center;"
					placeholder="请输入商品类目" />
			</view>
			<view class="text-select">
				<view class="" @click="popupShow = false">
					取消
				</view>
				<view class="">
					确定
				</view>
			</view>
		</u-popup>


		<u-picker mode="time" v-model="show1" :params="params" @confirm="confirm"></u-picker>
		<u-picker mode="time" v-model="show2" :params="params" @confirm="confirm1"></u-picker>


	</view>
</template>

<script>
	import headerBox from '../../components/header/header.vue'

	export default {
		components: {
			headerBox
		},
		data() {
			return {
				params: {
					year: true,
					month: true,
					day: true,
					hour: true,
					minute: true,
					second: false,
					province: true,
					timestamp: true,
				},
				title: '出库单',
				textList: [],
				addUrl: '',
				redactShow: false,
				show1: false,
				show2: false,
				list: [{
					name: '编辑',
					show: true
				}, {
					name: '删除',
					show: true
				}, {
					name: '取消',
					show: false
				}],
				tabText: 0,
				popupShow: false,
				redactShow1: false,
				redactShow2: false,
				stock: '1',
				total: '',
				page: '1', // 页面
				rows: 10, // 每页条数
				dataTime: '',
				endTime: '',
				valText: '',
				listFrom: [],
			}
		},
		onLoad(e) {},
		onShow() {
			this.getList()
			this.search2()
		},
		onReachBottom() {
			if(this.page * this.rows >= this.total) return this.$tools.msg('没有更多了！')
			this.page++
			this.getList()
		},
		methods: {

			async search() {
				const { data: res } = await this.$u.post("api/jinxiao.Back/index", {
					starttime: this.dataTime,
					endtime: this.endTime,
				})
				this.textList = res.list
				this.redactShow = false
			},
			
			async search1() {
				const { data: res} = await this.$u.post("api/jinxiao.Back/index", {
					keyword: this.valText,
				});
				this.textList = res.list
				this.redactShow1 = false
			},
			
			async search2() {
				const res = await this.$u.post("api/jinxiao.Store/index");
				this.listFrom = res.data
				this.redactShow2 = false
			},
			
			async search4(id) {
				const { data: res} = await this.$u.post("api/jinxiao.Back/index", {
					store_id: id,
				});
				this.textList = res.list
				this.redactShow2 = false
			},

			confirm(e) {
				console.log('确定选择', e)
				this.dataTime = e.year + '-' + e.month + '-' + e.day + ' ' + e.hour + ':' + e.minute
			},

			confirm1(e) {
				console.log('确定选择', e)
				this.endTime = e.year + '-' + e.month + '-' + e.day + ' ' + e.hour + ':' + e.minute
			},

			async getList() {
				const {
					data: res
				} = await this.$u.post("api/jinxiao.Back/index", {
					page: this.page,
					rows: this.rows,
				});
				this.textList = res.list
				this.total = res.total
			},


			elect(item, index) {
				console.log(index)
				this.tabText = index
				this.redactShow = item.show
				if (index == 0) {
					uni.navigateTo({
						url: '/pages/shopping/compile'
					})
					// 跳转到编辑页面
					// this.redactShow = true
				} else if (index == 1) {
					// 调用删除事件
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
	.conter {
		width: 100%;
		height: 100%;
		font-size: 24rpx;
		position: relative;

		image {
			width: 100%;
			height: 100%;
		}

		.text-tab {
			width: 100%;
			padding: 30rpx;
			padding-bottom: 0;
			// background-color: #FFFFFF;

			.box-width {
				color: #333333;
				width: 70% !important;
				margin-bottom: 30rpx;

				view {
					padding: 13rpx 23rpx;
					background: #EBEBF0;
					border-radius: 4rpx;
				}
			}

			.box {
				width: 100%;
				color: #666666;
				padding: 30rpx 30rpx 0;
				background-color: #FFFFFF;
				border-radius: 10rpx;
				margin-bottom: 30rpx;

				.box-title {
					width: 100%;
					display: flex;
					justify-content: space-between;
					align-items: center;
					height: 60rpx;
					font-size: 28rpx;
					font-weight: bold;
					color: #000000;
					font-family: PingFang SC;
					line-height: 60rpx;
				}

				.box-data {
					height: 60rpx;
					line-height: 60rpx;
				}

				.bot-bor {
					height: 88rpx;
					line-height: 88rpx;
				}
			}

			.box-width {
				width: 90%;
			}

			.marige-bor {
				width: 100%;
				margin: 0 auto;
				color: #333333;
				display: flex;
				font-size: 28rpx;
				align-items: center;
				background-color: #FFFFFF;
				border-top: 1rpx solid #F0F0F0;
				justify-content: space-between;

				.diso-flex {
					width: 90%;
					height: 80rpx;
					display: flex;
					align-items: center;
					justify-content: space-around;
				}

				.conter-image {
					width: 22rpx;
					height: 36rpx;
					font-weight: 700;
					color: #999;
				}
			}

			.marige-bor:last-child {
				border-bottom: 0;
			}
		}

		// 加号
		.add {
			position: fixed;
			bottom: 200rpx;
			right: 40rpx;
			width: 140rpx;
			height: 140rpx;
			text-align: center;
			line-height: 100rpx;
			border-radius: 50%;
			font-size: 100rpx;
			color: #FFFFFF;
			opacity: 0.9;
		}

		.total {
			width: 100%;
			position: absolute;
			bottom: 0;
			left: 0;
			height: 100rpx;
			padding: 0 60rpx 0 30rpx;
			background-color: #FFFFFF;
		}

	}

	.padd-text {
		width: 80%;
		height: 106rpx;
		line-height: 106rpx;
		text-align: center;
		font-size: 28rpx;
		color: #333;
		border-bottom: 1rpx solid #EEEEEE;
		margin: 0 auto;
	}

	.color-text {
		color: #7278EC;
	}

	.none-color {
		color: #000;
	}

	.input-text {
		width: 100%;
		height: 80rpx;
		line-height: 80rpx;
		text-align: center;
		margin-top: 10rpx;
	}

	.input-val {
		width: 80%;
		height: 78rpx;
		margin: 0 auto;
	}

	.text-select {
		width: 90%;
		margin: 0 auto;
		border-top: 1rpx solid #F0F0F0;
		display: flex;
		// padding-top: 20rpx;
		justify-content: space-around;

		view {
			width: 50%;
			height: 80rpx;
			line-height: 80rpx;
			text-align: center;
			border-right: 1rpx solid #F0F0F0;
		}

		view:last-child {
			border-right: 0;
		}
	}

	.flex-box1 {
		display: flex;
		margin: 0 30rpx;
		justify-content: space-around;
	}


	.flex-box2 {
		margin: 0 30rpx;
		display: flex;
		justify-content: space-around;
		align-items: center;

		view {
			line-height: 50rpx;
		}
	}

	.box1 {
		display: flex;
		align-items: center;
		justify-content: space-around;
		margin: 0 30rpx;

		.box-bgc {
			width: 330rpx;
			height: 60rpx;
			text-align: center;
			line-height: 60rpx;
			border-radius: 6rpx;
			background-color: #F2F3F7;
		}
	}

	.search-box {
		width: 90%;
		height: 70rpx;
		line-height: 70rpx;
		font-size: 28rpx;
		border-radius: 35rpx;
		margin: 20rpx auto 50rpx;
		text-align: center;
	}

	.cen {

		.padding-eft {
			width: 90%;
			height: 76rpx;
			margin: 0 auto;
			line-height: 76rpx;
			padding-left: 0;
			border-bottom: 1rpx solid #F5F5F5;

			view {
				width: 100%;
			}
		}

		.padding-eft:last-child {
			border-bottom: 0;
		}
	}
</style>
